testlistview: Show the row number
authorBenjamin Otte <otte@redhat.com>
Tue, 25 Sep 2018 23:41:39 +0000 (01:41 +0200)
committerMatthias Clasen <mclasen@redhat.com>
Sat, 30 May 2020 23:26:45 +0000 (19:26 -0400)
Always show the current row. This is mostly useful for debugging, not
for beauty.

tests/testlistview.c

index 6ccea1872855e1fb20758d6321f95521d2d08d31..14d4cddbf0e2474f93a95ce7643949308e72588b 100644 (file)
@@ -148,12 +148,19 @@ bind_widget (GtkListItem *list_item,
   guint depth;
   GIcon *icon;
   gpointer item;
+  char *s;
 
   item = gtk_list_item_get_item (list_item);
 
   box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4);
   gtk_list_item_set_child (list_item, box);
 
+  child = gtk_label_new (NULL);
+  gtk_label_set_width_chars (GTK_LABEL (child), 5);
+  gtk_label_set_xalign (GTK_LABEL (child), 1.0);
+  g_object_bind_property (list_item, "position", child, "label", G_BINDING_SYNC_CREATE);
+  gtk_box_append (GTK_BOX (box), child);
+
   depth = gtk_tree_list_row_get_depth (item);
   if (depth > 0)
     {
@@ -191,7 +198,9 @@ bind_widget (GtkListItem *list_item,
     }
 
   file = g_object_get_data (G_OBJECT (info), "file");
-  child = gtk_label_new (g_file_get_basename (file));
+  s = g_file_get_basename (file);
+  child = gtk_label_new (s);
+  g_free (s);
   g_object_unref (info);
 
   gtk_box_append (GTK_BOX (box), child);